/**
 * BatchInfoDAOImpl.java - 2012-2-10
 *
 * Licensed Property to China UnionPay Co., Ltd.
 * 
 * (C) Copyright of China UnionPay Co., Ltd. 2010
 *     All Rights Reserved.
 *
 * Project Info: China UnionPay Internet Acquiring Project
 * 
 * Modification History:
 * =============================================================================
 *   Author         Date          Description
 *   ------------ ---------- ---------------------------------------------------
 *        
 * =============================================================================
 */
package com.lijin.batchsys.framework.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.springframework.jdbc.core.RowCallbackHandler;

import com.lijin.batchsys.framework.common.BatchUtil;
import com.lijin.batchsys.framework.dao.model.BatchInfo;

/**
 * Description: 批次信息DAO实现类
 *
 * (C) Copyright of China UnionPay Co., Ltd. 2010.
 *
 *  @author Han bowen
 *  @time  2012.02.21 
 */
public class BatchInfoDAO extends BaseDAO {

	/**
	 * 获得所有的批次信息
	 * @return
	 */
	public List<BatchInfo> getAllBatchInfo() {
		final List<BatchInfo> batchList = new ArrayList<BatchInfo>();
		
		this.getJdbcTemplate().query(BatchSysSQL.getInstance().fetchSQL(BatchSysSQL.SQL_SELECT_ALL_BATCH), new RowCallbackHandler() {
			
			@Override
			public void processRow(ResultSet rs) throws SQLException {
				BatchInfo batch = new BatchInfo();
				batch.setId(rs.getInt("ID"));
				batch.setBatchNo(rs.getInt("BATCH_NO"));
				batch.setBatchDesc(rs.getString("BATCH_DESC"));
				batch.setBatchRunType(rs.getString("RUN_TYPE"));
				//转换批次运行类型变为汉字显示
				batch.setRunTypeToStr(BatchUtil.batchRunTypeToStr(rs.getString("RUN_TYPE")));
				batch.setBatchRunTmConfig(rs.getString("RUN_TM_CONFIG"));
				batch.setRecSt(rs.getString("REC_ST"));
				batchList.add(batch);
			}
		});
		
		return batchList;
	}
}
